﻿using System.Web.Mvc;
using FrontEnd.Controllers;
using Xunit;

namespace UnitTests.Controllers.Membership
{
    public class When_User_Try_To_Authenticate
    {
        [Fact]
        public void Should_Authenticate_And_Return_Credentials_Are_Valid()
        {
            const string fakeEmail = "fake@example.com";
            const string fakePassword = "fakepassword";
            const string etalonRedirectUrl = "/somewere/";

            var environment = new TestEnvironment();
            environment.AddFakeAccount(fakeEmail, fakePassword);
            MembershipController controller = environment.Build();

            // Execute
            RedirectResult result = (RedirectResult)controller
                .Authenticate(fakeEmail, fakePassword, false, etalonRedirectUrl);

            //Verify
            Assert.Equal(etalonRedirectUrl, result.Url);            
        }
    }
}
